﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<!-- search -->
<div class="box_search w_980">
	<!--上面圆角背景-->
	<b class="box_search_top"></b>
	<!--中间标签-->
    <div class="box_search_main">
    	<!--标签-->
    	<div class="index_search_tag clearfix">
            <ul class="clearfix">
            	<!--按读书年龄层-->
                <li class="li_1">
                    <dl>
                        <dt>按语种</dt>
                        <dd>
                            <% 
                                foreach (string s in Enum.GetNames(typeof(DAL.Enums.booklanguage)))
                                {
                                    int _v = (int)Enum.Parse(typeof(DAL.Enums.booklanguage), s);
                                    int l=Request["l"]==null?-1:int.Parse(Request["l"].ToString());
                                    Response.Write("<a  " + (l == _v ? "class=\"red\"" : "") + " href=\"/list.html?l=" + _v + "\">" + s + "</a>");
                                }
                            %>
                        </dd>
                    </dl>
                </li>
            	<!--按出版社-->
                <li class="li_2">
                    <dl>
                        <dt>按主题</dt>
                        <dd>
                            <% 
                                foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookTheme)))
                                {
                                    int _v = (int)Enum.Parse(typeof(DAL.Enums.bookTheme), s);
                                    int l=Request["z"]==null?-1:int.Parse(Request["z"].ToString());
                                    Response.Write("<a  " + (l == _v ? "class=\"red\"" : "") + " href=\"/list.html?z=" + _v + "\">" + s + "</a>");
                                }
                            %>
                        </dd>
                    </dl>
                </li>
            	<!--按级别-->
                <li class="li_3">
                    <dl>
                        <dt>按级别</dt>
                        <dd>
                            <% 
                                foreach (string s in Enum.GetNames(typeof(DAL.Enums.boollevel)))
                                {
                                    int _v = (int)Enum.Parse(typeof(DAL.Enums.boollevel), s);
                                    int l=Request["le"]==null?-1:int.Parse(Request["le"].ToString());
                                    Response.Write("<a  " + (l == _v ? "class=\"red\"" : "") + " href=\"/list.html?le=" + _v + "\">" + s + "</a>");
                                }
                            %>
                        </dd>
                    </dl>
                </li>
                <!--按阅读年龄-->
                <li class="li_6">
                    <dl>
                        <dt>按阅读年龄</dt>
                        <dd>
                            <% 
                                foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookforAge)))
                                {
                                    int _v = (int)Enum.Parse(typeof(DAL.Enums.bookforAge), s);
                                    int l=Request["y"]==null?-1:int.Parse(Request["y"].ToString());
                                    Response.Write("<a  " + (l == _v ? "class=\"red\"" : "") + " href=\"/list.html?y=" + _v + "\">" + s.Replace("_", "") + "</a>");
                                }
                            %>
                        </dd>
                    </dl>
                </li>
            	<!--按类型-->
                <li class="li_4">
                    <dl>
                        <dt>按类型</dt>
                        <dd>
                            <% 
                                foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookType)))
                                {
                                    int _v = (int)Enum.Parse(typeof(DAL.Enums.bookType), s);
                                    int l=Request["x"]==null?-1:int.Parse(Request["x"].ToString());
                                    Response.Write("<a  " + (l == _v ? "class=\"red\"" : "") + " href=\"/list.html?x=" + _v + "\">" + s.Replace("_", "/") + "</a>");
                                }
                            %>
                        </dd>
                    </dl>
                </li>
            	<!--按书的状态-->
                <li class="last li_5">
                    <dl>
                        <dt>按书的状态</dt>
                        <dd>
                            <% 
                                foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookebook)))
                                {
                                    int _v = (int)Enum.Parse(typeof(DAL.Enums.bookebook), s);
                                    int l=Request["e"]==null?-1:int.Parse(Request["e"].ToString());
                                    Response.Write("<a  "+(l==_v?"class=\"red\"":"")+" href=\"/list.html?e=" + _v + "\">" + s + "</a>");
                                }
                            %>
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
	<!--下面搜索-->
	<div class="box_search_bottom list_search">
    	<div class="search_input_box">
        	<input id="inputSearch" type="text" value="<%=Request["tt"] == null ? "输入书名/译名/isbn/出版社/作者 条件之间用空格分隔": Request["tt"].ToString()%>" />
            <a href="javascript:void(0);" id="aSearch">搜索</a>
        </div>
        <ul>
        	<li>热门绘本：</li>
            <% 
                BIZ.InfomationPublishOper ipo = new BIZ.InfomationPublishOper();
                IList li = ipo.getlistweb(1, 6, (int)DAL.Enums.template.热门绘本);
                foreach(Hashtable tb in li)
                {
                    if (tb["total"]==null)
                        Response.Write("<li><a target=\"_blank\" href=\"" + (tb["i_dataLink"] == null ? "" : tb["i_dataLink"].ToString()) + "\">" + (tb["i_title0"] == null ? "" : tb["i_title0"].ToString()) + "</a></li>");
                }
            %>        
        </ul>
        <%if (Request.Url.ToString().IndexOf("list.html") > -1)
          { %>
        <div id="otherSearch">
         <ul>
        	<li><label><input id="t1" name="" chooseValue="<%=BIZ.Common.ListUrlToolcs.locateSearch(Request,null,null,null,null,null,null,"1",null,null,null,null) %>" unchooseValue="<%=BIZ.Common.ListUrlToolcs.locateSearch(Request,null,null,null,null,null,null,"0",null,null,null,null) %>" type="checkbox" value="" <%=(Request["cd"]!=null ? "checked":"") %>/>CD</label></li>
        	<li><label><input name="" chooseValue="<%=BIZ.Common.ListUrlToolcs.locateSearch(Request,null,null,null,null,null,null,null,"1",null,null,null) %>" unchooseValue="<%=BIZ.Common.ListUrlToolcs.locateSearch(Request,null,null,null,null,null,null,null,"0",null,null,null) %>" type="checkbox" value="" <%=(Request["mp3"]!=null ? "checked":"") %> />视频文件</label></li>
        	<li><label><input name="" chooseValue="<%=BIZ.Common.ListUrlToolcs.locateSearch(Request,null,null,null,null,null,null,null,null,"1",null,null) %>" unchooseValue="<%=BIZ.Common.ListUrlToolcs.locateSearch(Request,null,null,null,null,null,null,null,null,"0",null,null) %>" type="checkbox" value="" <%=(Request["inventory"]!=null ? "checked":"") %> />还有库存</label></li>
        </ul>
        </div>
        <%}
             %>
    </div>
    <script language="javascript" type="text/javascript">
        //去左空格; 
        function ltrim(s) {
            return s.replace(/^\s*/, "");
        }
        //去右空格; 
        function rtrim(s) {
            return s.replace(/\s*$/, "");
        }
        //去左右空格; 
        function trim(s) {
            return rtrim(ltrim(s));
        }
        $(document).ready(function () {
            var search = $("#inputSearch");
            search.focus(function () {
                if (search.val() == "输入书名/译名/isbn/出版社/作者 条件之间用空格分隔") {
                    search.val("");
                }

            });
            search.blur(function () {
                if (trim(search.val()) == "") {
                    search.val("输入书名/译名/isbn/出版社/作者 条件之间用空格分隔");
                }
            });
            $("#aSearch").click(function () {
                if (search.val() != "输入书名/译名/isbn/出版社/作者 条件之间用空格分隔") {
                    window.location.href = "/list.html?tt=" + encodeURI(trim(search.val()));
                }
            });
            $("#otherSearch input").click(function () {
                if ($(this).attr("checked")) {
                    location.href = "/list.html" + $(this).attr("chooseValue");
                }
                else {
                    location.href = "/list.html" + $(this).attr("unchooseValue");
                }
            });
        });
    </script>
</div>